<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Models\AdTask
 *
 * @property int $id
 * @property string|null $ad_title
 * @property string|null $ad_content
 * @property int $target_read_amount
 * @property int $current_read_amount
 * @property int $status
 * @property int $enable
 * @property int $user_id
 * @property int $type
 * @property int $live_time
 * @property string|null $img_urls
 * @property string|null $link
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property string|null $deleted_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\AdTask onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereAdContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereAdTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereCurrentReadAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereEnable($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereImgUrls($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereLink($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereLiveTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereTargetReadAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdTask whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\AdTask withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\AdTask withoutTrashed()
 * @mixin \Eloquent
 */
class AdTask extends Model
{
    use SoftDeletes;

    public function setPicturesAttribute($pictures)
    {
        if (is_array($pictures)) {
            $this->attributes['pictures'] = json_encode($pictures);
        }
    }

    public function getPicturesAttribute($pictures)
    {
        return json_decode($pictures, true);
    }
}
